/**
 * 
 */
package com.hurr.assembly;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;

import com.hurr.assembler.Assembler;
import com.hurr.bo.Deposit;
import com.hurr.dto.DepositDto;

/**
 * @author Fernando Perelli
 *
 */
public class DepositAssembly {
	
	
	public DepositDto toDto(Deposit deposit) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		DepositDto depositDto = new DepositDto();
		depositDto.setId(deposit.getId());
		depositDto.setDate(deposit.getDate());
		depositDto.setDescription(deposit.getDescription());
		depositDto.setType(deposit.getType());
		depositDto.setValue(deposit.getValue());
		return depositDto;
	}
	
	public Deposit toModel(DepositDto depositDto) throws InstantiationException, IllegalAccessException, ClassNotFoundException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException{
		Deposit deposit = new Deposit();
		deposit.setId(depositDto.getId());
		deposit.setDate(depositDto.getDate());
		deposit.setDescription(depositDto.getDescription());
		deposit.setType(depositDto.getType());
		deposit.setValue(depositDto.getValue());
		return deposit;
	}

	public Collection<DepositDto> toDtos(Collection<Deposit> deposits) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
		Collection<DepositDto> depositDtos = new ArrayList<DepositDto>();
		for (Deposit deposit : deposits) {
			DepositDto depositDto = (DepositDto) Assembler.toDto(deposit);
			depositDtos.add(depositDto);
		}
		return depositDtos;
	}
	
	public Collection<Deposit> toModels(Collection<DepositDto> depositDtos) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException{
		Collection<Deposit> deposits = new ArrayList<Deposit>();
		
		for (DepositDto depositDto : depositDtos) {
			Deposit deposit= (Deposit) Assembler.toModel(depositDto);
			deposits.add(deposit);
		}
		return deposits;
		
	} 


}
